﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Management/Manage.Master"  %>
<%@ Import Namespace="CSI.Directory.Core.Model"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Edit Menu
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
      $(document).ready(function () {

        $("a").removeClass("current");
        $("#menus").addClass("current");
        var e = jQuery.Event("click");
        $("#menus").trigger(e);
        $("#edit-menu").addClass("current");
    });
</script>
    <div class="content-box">
        <!-- Start Content Box -->
        <div class="content-box-header">
            <h3>
                Edit Menu</h3>
            
            <div class="clear">
            </div>
        </div>
        <!-- End .content-box-header -->
        <div class="content-box-content">
            <div class="tab-content default-tab" id="tab1">
        
    
   <form action="/Management/EditMenu" name="form1" method="post">
<fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->		
    <div style=" float:left; width:80px;"><label>Order</label></div>
    <div class="editor-field" style=" float:left; width:600px"><input value="<%=((CSI.Directory.Core.Model.Menu)(ViewData["menu"])).Order %>" class="text-input small-input" type="text" id="Order" name="Order" size="550px"/> </div>
			
    <div style="clear:both; padding:3px"></div>
            
    <div style=" float:left; width:80px;"><label>Name</label></div>
    <%--<input value="<%=((CSI.Directory.Core.Model.Menu)(ViewData["menu"])).Title %>" class="text-input small-input" type="text" id="Title" name="Title" /> --%>
    <div style=" float:left; width:600px" class="editor-field"><input value="<%=((CSI.Directory.Core.Model.Base)(ViewData["menu"])).Name %>" class="text-input small-input" type="text" id="Title" name="Title"  size="550px"/> </div>
    <div style="clear:both; padding:3px"></div>
        <input name="id" value="<%=((CSI.Directory.Core.Model.Menu)(ViewData["menu"])).Id %>" type="hidden" />  
                  
        <div style="margin-left:80px"><input type="button" onclick="return DoAjaxSubmit(this);" value="Save" class="button" style="text-decoration:none"/></div>
    <div style="clear:both; padding:3px"></div>
    <div id="results"></div>
    <div>
     <%= Html.ActionLink("Back to List", "ShowMenu") %>
    </div>
</fieldset>
   </form>
    </div>
        </div>
   </div>
     <script type="text/javascript">
         function DoAjaxSubmit(btnClicked) {
             var form = $(btnClicked).parents('form');
             if ($("#Title").val() == "" || $("#Order").val() == "") {
                 $("#results").html("Please complete all fields").addClass("red");
                 return false;
             }
             else {
                 $("#results").html("");
                 $.ajax({
                     type: "POST",
                     url: form.attr('action'), //'<%=ResolveUrl("~/register/go") %>',
                     data: form.serialize(),
                     error: function (xhr, status, error) {
                     },
                     success: function (response) {
                         if (response != null) {
                             if (!response.Successful) {
                                 $("#results").html("An error occurred: " + response.Exception).addClass("red");
                                 return false;
                             }
                             else {
                                 $("#results").html("Menu updated").addClass("green");

                             }
                         }
                     }
                 });
             }
             return false;
         }
    </script>
</asp:Content>
